import request from '@/config/axios'

export interface ScheduleVO{
  id: number
  doctorName: string
  doctorId: number
  date: string
  morningStart: string
  morningEnd: string
  morningCapacity: number
  afternoonStart: string
  afternoonEnd: string
  afternoonCapacity: number
  status: number
  createTime: Date
  morningCount: number
  afternoonCount: number
}

// 查询排班管理列表
export const getSchedulePage = (params: PageParam) => {
  return request.get({ url: '/medical/schedules/page', params })
}

// 查询排班详情
export const getSchedule = (id: number) => {
  return request.get({ url: '/medical/schedules/get?id=' + id })
}

// 新增排班
export const createSchedule = (data: ScheduleVO) => {
  return request.post({ url: '/medical/schedules/create', data })
}

// 修改排班
export const updateSchedule = (data: ScheduleVO) => {
  return request.put({ url: '/medical/schedules/update', data })
}

// 删除排班
export const deleteSchedule = (id: number) => {
  return request.delete({ url: '/medical/schedules/delete?id=' + id })
}

// 导出排班
export const exportSchedule = (params) => {
  return request.download({ url: '/medical/schedules/export', params })
}

// 下载排班导入模板
export const importScheduleTemplate = () => {
  return request.download({ url: '/medical/schedules/get-import-template' })
}


// 排班状态修改
export const updateScheduleStatus = (id: number, status: number) => {
  const data = {
    id,
    status
  }
  return request.put({ url: '/medical/schedules/update-status', data: data })
}

// 获取排班精简信息列表
export const getSimpleUserList = (): Promise<ScheduleVO[]> => {
  return request.get({ url: '/medical/schedules/simple-list' })
}

// 获取某医生排班列表
export const getDoctorScheduleList = (doctorId: number, today: String) => {
  return request.get({ url: '/medical/schedules/doctor-schedule?doctorId=' +
                       doctorId + '&today=' + today })
}